#include "foldermodel.h"
#include "../../../11-util/03-path_manager/pathmanager.h"
#include <QPixMap>
#include <QtSvg/QSvgRenderer>
#include <QPainter>
FolderModel::FolderModel() {}

FolderModel::FolderModel(QString fullName,int unreadCount,int mailCount,FolderType type) {
    this->fullName = fullName;
    this->name = PathManager::getName(fullName);
    this->unreadCount = unreadCount;
    this->mailCount = mailCount;
    this->type = type;
}

/**
 * 1,需要添加缓存.
 * 2,缓存何时需要更新,type值改变时,需要置空,重新生成缓存.
 * @brief FolderModel::getIcon
 * @return
 */
QIcon FolderModel::getIcon() {
    if(mIcon == nullptr) {
        QPixmap * pixmap = new QPixmap(32,32);
        QString svgPath = ":/new/prefix1/12-resources/01-svg/Svg_FolderList_Inbox.svg";
        QSvgRenderer * svg_render = new QSvgRenderer(svgPath);
        pixmap->fill(Qt::transparent);
        QPainter painter(pixmap);
        svg_render->render(&painter);
        mIcon =new QIcon(*pixmap);
    }
    return *mIcon;
}
